package com.ella.controller;
import com.google.code.kaptcha.Producer;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.imageio.ImageIO;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.awt.image.BufferedImage;
import java.io.IOException;
@RestController
@RequestMapping("/sys-verity")
public class SysVerifyCodeController {

	@Resource
	private Producer producer;

	@GetMapping("/demo1")
	public void GetVerityImage(HttpServletResponse response) throws IOException {
		//生成验证码
		String code = producer.createText();
		//生成图片,同时响应给前端
		BufferedImage image = producer.createImage(code);
		response.setContentType("image/png");
		ServletOutputStream outputStream = response.getOutputStream();
		ImageIO.write(image,"png",outputStream);
	}
	@GetMapping("/demo2")
	public void Demo2(){
		System.out.println("你是一头猪吗");
	}



}
